// 所有学生
<script>
export default {
  data() {
    return {
      pagination: {
        //分页后的学生成绩信息
        page: 1, //当前页
        total: null, //记录条数
        size: 6, //每页条数
        records: [{}],
      },
    };
  },
  created() {
    this.getAnswerInfo();
  },
  methods: {
    getAnswerInfo() {
      let teacherId = this.$cookies.get("cid");
      //分页查询所有学生成绩信息
      this.$axios(
        `/api/uStudents/checkStudentScore/${teacherId}/${this.pagination.page}/${this.pagination.size}`
      )
        .then((res) => {
          this.pagination.records = res.data.data.data;
          this.pagination.total = res.data.data.total;
        })
        .catch((error) => {});
    },
    //改变当前记录条数
    handleSizeChange(val) {
      this.pagination.size = val;
      this.getAnswerInfo();
    },
    //改变当前页码，重新发送请求
    handleCurrentChange(val) {
      this.pagination.page = val;
      this.getAnswerInfo();
    },
    checkGrade(scoreid) {
      //删除当前学生
      this.$confirm("确定无异议吗？修改后无法恢复", "Warning", {
        confirmButtonText: "确定无异议",
        cancelButtonText: "算了,留着,有待商榷",
        type: "danger",
      })
        .then(() => {
          //确认删除
          this.$axios({
            url: `/api/uStudents/updateScoreStatus`,
            method: "put",
            data: {
              scoreid,
            },
          }).then((res) => {
            if (res.data.code == 200) {
              this.$message({
                message: "更新成功",
                type: "success",
              });
            }
            this.getAnswerInfo();
          });
        })
        .catch(() => {});
    }
  },
};
</script>
<template>
  <div class="all">
    <el-table :data="pagination.records" border>
       <el-table-column fixed="left" label="图片">
          <template scope="scope">
            <img :src="scope.row.image" width="45" height="45">
          </template>
      </el-table-column>
      <el-table-column
        prop="studentname"
        label="姓名"
        width="120"
      ></el-table-column>
      <el-table-column
        prop="institute"
        label="学院"
        width="200"
      ></el-table-column>
      <el-table-column prop="major" label="专业" width="200"></el-table-column>
      <el-table-column prop="grade" label="年级" width="100"></el-table-column>
      <el-table-column prop="clazz" label="班级" width="100"></el-table-column>
      <el-table-column
        prop="papername"
        label="试卷"
        width="200"
      ></el-table-column>
      <el-table-column prop="score" label="成绩" width="120"></el-table-column>

      <!-- <el-table-column prop="status" label="审核" width="120"></el-table-column> -->
      <el-table-column fixed="right" label="审核" width="150">
        <template slot-scope="scope">
          <el-button
            @click="checkGrade(scope.row.scoreid)"
            type="primary"
            size="small"
            >{{ scope.row.status }}</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pagination.current"
      :page-sizes="[6, 10]"
      :page-size="pagination.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pagination.total"
      class="page"
    ></el-pagination>
  </div>
</template>

<style lang="scss" scoped>
.all {
  padding: 0px 40px;
  .page {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .edit {
    margin-left: 20px;
  }
  .el-table tr {
    background-color: #dd5862 !important;
  }
}
.el-table .warning-row {
  background: #000 !important;
}

.el-table .success-row {
  background: #dd5862;
}
</style>
